<?php
	/**
	 * @author Matthias Eigner | 0625203
	 */
	class Project{
		private $id;
		private $title;
		private $description;
		private $todo_count;
		private $message_count;
		private $last_todo;
		private $last_todo_date;
		private $todo_finished;
		private $todo_on_schedule;
		private $todo_behind_schedule;
		private $todo_waiting;
		private $todo_new;
		private $owner;
		private $todos;
		private $users;
		private $list_count;
		
		const STATUS_PUBLIC=0;
		const STATUS_PRIVATE=1;
		
		function __construct($id, $title, $desc, $todo_count, $last_todo, $last_todo_date, $todo_finished, $todo_on_schedule, $todo_behind_schedule, $todo_waiting, $todo_new, $owner, $status=self::STATUS_PUBLIC) {
			$this->id = $id;
			$this->title = $title;
			$this->description = $desc;
			$this->todo_count = $todo_count;
			$this->last_todo = $last_todo;
			$this->last_todo_date = $last_todo_date;
			$this->todo_finished = $todo_finished;
			$this->todo_on_schedule = $todo_on_schedule;
			$this->todo_behind_schedule = $todo_behind_schedule;
			$this->todo_waiting = $todo_waiting;
			$this->todo_new = $todo_new;
			$this->owner = $owner;
			$this->message_count = 0;
			$this->todos = array();
			$this->status = $status;
			$this->users = array();
		}
		
		/**
		 * 
		 * Adds Todo to Projects Todo array
		 * @param Todo $todo
		 */
		public function addTodo($todo){
			$this->todos[] = $todo;
		}
		public function setListCount($c){
			$this->list_count = $c;
		}
		
		/**
		 * 
		 * Adds an Array of Todos to Projects Todo array
		 * @param Todo[] $todo
		 */
		public function addTodos($todos){
			foreach($todos as $todo) $this->addTodo($todo);
		}
		
		public function loadUsers(){
			$this->users = $GLOBALS['Db-I']->getUsers($this->id);
		}
		
		public function setMsgCount($c){
			$this->message_count = $c;
		}
		
		//Getters
		public function getId() {
			return $this->id;
		}
		
		public function getTitle() {
			return $this->title;
		}
		
		public function getDescription() {
			return $this->description;
		}
		
		public function getTodoCount() {
			return $this->todo_count;
		}
		
		public function getMessageCount() {
			return $this->message_count;
		}
		
		public function getLastTodo() {
			return $this->last_todo;
		}
		
		public function getLastTodoDate() {
			
			return ($this->last_todo_date != '') ? date('d.m.Y', $this->last_todo_date) : '';
		}
		
		public function getTodoOnSchedule() {
			return $this->todo_on_schedule;
		}
		
		public function getTodoBehindSchedule(){
			return $this->todo_behind_schedule;
		}
		
		public function getTodoWaiting() {
			return $this->todo_waiting;
		}
		
		public function getTodoFinished() {
			return $this->todo_finished;
		}
		
		public function getTodoNew() {
			return $this->todo_new;
		}
		
		public function getOwner() {
			return $this->owner;
		}
		
		public function getTodos() {
			return $this->todos;
		}
		
		public function getStatus(){
			return $this->status;
		}
		
		public function getUsers(){
			return $this->users;
		}
		
		public function getListCount() {
			return $this->list_count;	
		}
	}
?>